<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    /** 会员列表 */
    public function index(Request $request)
    {
        $type = $request->input('type',1);
        if($request->isMethod('post')){
            $model = User::when(!empty($type),function($query)use($type){
                                $query->where('type',$type);
                            })
                            ->orderBy('login_at','desc')
                            ->paginate(config('base.limit'));
            return $this->data($model->items(),$model->total());
        }
        return view('user.user.index',['type'=>$type]);
    }
}
